package model.core;

import model.area_effect.Trap;
import utility.BidirectionalMap;

public class TrapsLibrary {
	private BidirectionalMap<String, Trap> library = new BidirectionalMap<String, Trap>();
	
	private static TrapsLibrary trapsLibrary = null;
	
	private TrapsLibrary(){
		
	}
	
	public static TrapsLibrary getInstance(){
		if (trapsLibrary == null){
			trapsLibrary = new TrapsLibrary();
		}
		return trapsLibrary;
	}
	
	public Trap getTrap(String name){
		try {
			return library.getFromSecondSet(name).clone();
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return library.getFromSecondSet(name);
	}
	
	public String getName(Trap t){
		return library.getFromFirstSet(t);
	}
	
	public void put(String name, Trap t){
		library.put(name, t);
	}
}
